public class Test7 {
    public static void main(String[] args) {
        String s1 ="hello";
        String s2 = " world";
        System.out.println(s1+s2);//hello world


        String string1 = "hello world hello world hello world";
        System.out.println(string1.substring(0,5));//截取小标为[0,5)的字符
        System.out.println(string1.substring(5));//截取第五个字符后面的所有字符




        String str20 = "127.0.0.1";
        String[] strings = str20.split("\\.");
        for (String s : strings) {
            System.out.println(s);
        }

        String[] strings1 = string1.split(" ",3);//将str按空格进行拆分成三份
        String string2 = "hello world hello world    hello world";
        String[] strings2 = string1.split(" ",6);//将str按空格进行拆分成六份
        for (String s : strings1) {
            System.out.println(s);
        }
        System.out.println("--------------------");
        for (String s : strings2) {
            System.out.println(s);
        }


        String string = String.format("整数：%d,浮点数：%f,字符：%c,字符串：%s",10,10.2,'a',"hello");
        System.out.println(string);//整数：10,浮点数：10.200000,字符：a,字符串：hello

        String s = "hello";
        char[] ch = s.toCharArray();// 字符串转数组
        String s3 = new String(ch);//数组转字符串


        String str = "aBcDeFgH";
        System.out.println(str.toUpperCase());//ABCDEFGH
        System.out.println(str.toLowerCase());//abcdefgh

        String str1 = String.valueOf(1234);//整数转字符串
        String str2 = String.valueOf(12.34);//浮点数转字符串
        String str3 = String.valueOf(true);//布尔值转字符串
        String str4 = String.valueOf(new Person("02",18));//对象转字符串
        int a = Integer.parseInt(str1);//字符串转整数
        double b = Double.parseDouble(str2);//字符串转浮点数
        boolean c = Boolean.parseBoolean(str3);//字符串转布尔值




        String str5 = "abcdabcdabcd";
        System.out.println(str.contains("abcd"));//true
        System.out.println(str.contains("abcde"));//false
        System.out.println(str.lastIndexOf('a'));//8
        System.out.println(str.indexOf("abcd"));//8
        System.out.println(str.indexOf('a'));//0
        System.out.println(str.indexOf('d'));//3
        System.out.println(str.charAt(1));//b
        System.out.println(str.charAt(3));//h




        String s8 = "abc";
        String s4 = "ABC";
        System.out.println(s8.compareToIgnoreCase(s2));//0
        String s10 = new String("abc");
        String s9 = new String("ac");
        String s5 = new String("ad");
        String s6 = new String("abcde");
        String s7 = new String("abc");
        String str10 ="1";
        String st11 = "1";
        System.out.println(s6.compareTo(s7));//-1
        System.out.println(s6.compareTo(s3));//-2
        System.out.println(s6.compareTo(s4));//-2
        System.out.println(s6.compareTo(s5));//0
        if (str1.compareTo(s7)==0){

        }
    }
}
